network object

This method will initialise and set up the network object in server mode.

bool setup_server(int listening_port, int channels, int max_peers)

Parameters:
listening_port
The port that is to be used while listening for a connection.
channels
The number of channels that are used by the client. The maximum is 100.
max_peers
The maximum number of peers that the server can be connected with simultaneously. The maximum is 4000.

Return value:
true if the server was set up successfully, false otherwise.

Remarks:
This method is used to set up the network object in server mode. Once the server has been set up, it will automatically listen for connections on the given port. Whenever a new peer tries to connect, an event of type connect will be received.

Please note that it is perfectly legal for a server to make outgoing connections as well. These outgoing connections will be part of the same list of peers as the incoming connections, meaning that both incoming and outgoing connections on the server will count towards the maximum peer count. Thus, a server may act both as a server and as a client at one and the same time.

Example:
See the main network chapter.